package com.portal.web.action.system.user;


import com.portal.model.ResultMessage;
import com.portal.model.system.User;
import com.portal.web.action.BaseAction;

/**
 * 用户管理删除
 * @author liu.qiao
 *
 */
public class Delete extends BaseAction {
	private static final long serialVersionUID = 1L;
	private String id;
	private ResultMessage result = new ResultMessage("0", "");

    public String execute() throws Exception {
    	try {
    		User user = (User)this.getServiceContainer().getUserService().read(id);
    		if(user!=null){
    			this.getServiceContainer().getUserService().delete(id);
    		}else{
    			setResult(new ResultMessage("100", "ID[" +id+ "]的用户信息不存在！"));
    			return ERROR;
    		}
		} catch (Exception e) {
			e.printStackTrace();
			setResult(new ResultMessage("100", "删除用户失败！"));
			return ERROR;
		}
		setResult(new ResultMessage("0", "删除用户成功！"));
        return SUCCESS;
    }

	public ResultMessage getResult() {
		return result;
	}

	public void setResult(ResultMessage result) {
		this.result = result;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
